home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group03a.txt / 000091_icon-group-sender_Thu Sep 18 07:29:38 2003.msg < prev    next >
Internet Message Format  |  2003-12-22  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id h8IET7F18427
  4.     for icon-group-addresses; Thu, 18 Sep 2003 07:29:07 -0700 (MST)
  5. Message-Id: <200309181429.h8IET7F18427@baskerville.CS.Arizona.EDU>
  6. To: Steve Wampler <swampler@noao.edu>
  7. cc: icon-group@cs.arizona.edu
  8. Subject: Re: Simple Icon programming challenge... 
  9. Date: Wed, 17 Sep 2003 23:15:25 -0700
  10. From: William Griswold <wgg@cs.ucsd.edu>
  11. X-Spam-Status: No, hits=-5.1 required=5.0
  12.     tests=BAYES_10,IN_REP_TO
  13.     version=2.55
  14. X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)
  15. Errors-To: icon-group-errors@cs.arizona.edu
  16. Status: RO
  17.  
  18. Hi Steve,
  19.  
  20. Here is my solution.  I got a little too clever for my own good, but
  21. I enjoyed it. :)
  22.  
  23. --bill
  24.  
  25.  
  26. procedure main()
  27.   every !&input ? {
  28.     while not pos(0) do {
  29.       writes(nextpiece())
  30.       writes(scrambleinnards(nextpiece()))
  31.       }
  32.     write()
  33.     }
  34. end
  35.  
  36. #
  37. # Scramble internal letters of a string with replacement.  Without seemed
  38. # hard.  Note that pretty much any letter-preserving function would work,
  39. # if you didn't care about randomness.
  40. #
  41. procedure scrambleinnards(word)
  42.   every !word[2:*word] :=: ?word[2:*word]
  43.   return word
  44. end
  45.  
  46. #
  47. # State machine semantics for retrieving the word and non-word parts
  48. # of a text.  First retrieves a non-word, then a word, etc.  Would be
  49. # more efficient with a swap rather than a complement.
  50. #
  51. procedure nextpiece()
  52.   static current
  53.   initial current := &ucase ++ &lcase   # letters
  54.   return tab(many(current := ~current))
  55. end
  56.  
  57.  
  58.  
  59. In msg <200309172032.h8HKWPJ20725@baskerville.CS.Arizona.EDU>, Steve Wampler sa
  60. ys:
  61. >(This is probably a good string scanning exercise for newer
  62. >Icon programmers...)
  63. >
  64. >Yesterday there were some news reports of a finding from an
  65. >English University on just how well most of us read.  In
  66. >particular, they found that people could read nearly as fast
  67. >if the interior letters (all but the first and last) of
  68. >words were scrambled, provided people tried to read it fast
  69. >and didn't spend time focussing on each word.
  70. >
  71. >For example, one scrambling of the above paragraph is:
  72. >
  73. >Ysaeterdy trhee wree smoe nwes roetprs of a fdinnig form an
  74. >Eingslh Usnivetriy on jsut how wlel msot of us raed.  In
  75. >paarticulr, tehy fnoud taht ppeloe cloud raed nalery as fsat
  76. >if the ionterir lrettes (all but the fsirt and lsat) of
  77. >wdors wree smcreabld, perovidd pleope tierd to raed it fsat
  78. >and ddin't snped tmie fsocunsig on ecah wrod.
  79. >
  80. >This actually may have profound implications on the ability
  81. >of spam-blocking software to perform properly.
  82. >
  83. >Not that I want to promote spam, but...
  84. >
  85. >Write an Icon (or Unicon!) program that scrambles input
  86. >using to this approach.  It would be nice if it produced
  87. >random scramblings (where repeated runs of the program on
  88. >the same input produce different results).
  89. >
  90. >-- 
  91. >Steve Wampler -- swampler@noao.edu
  92. >Quantum materiae materietur marmota monax si marmota
  93. >                    monax materiam possit materiari?
  94. >
  95.